package com.jml.zlhq.app.widgets;

import java.io.Serializable;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class MyViewPager extends ViewPager implements Serializable{

	private static final long serialVersionUID = -7768183012059705556L;
	int mLastMotionY;
	int mLastMotionX;
	
	private SuperOnTouchEvent sotEvt;
	
	public MyViewPager(Context context) {
		super(context);
	}
	
	public MyViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		//getParent().requestDisallowInterceptTouchEvent(true); //只需这句话，让父类不拦截触摸事件就可以了。
        return super.dispatchTouchEvent(ev);
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent arg0) {
		return sotEvt!=null&&!sotEvt.isAllowSuperTouch()?false:super.onTouchEvent(arg0);
	}
	
	@Override
	public boolean onInterceptTouchEvent(MotionEvent arg0) {
		return sotEvt!=null&&!sotEvt.isAllowSuperTouch()?false:super.onInterceptTouchEvent(arg0);
	}
	
	public void setSuperOnTouchEvent(SuperOnTouchEvent sotEvt){
		this.sotEvt = sotEvt;
	}
	
	public interface SuperOnTouchEvent{
		public boolean isAllowSuperTouch();
	}
	
	
}